#include "physic.hpp"

#include "physic_impl.hpp"
#include "ammo/game/gameobject.hpp"

namespace ammo
{

namespace //anonymous
{
	class NullPhysicImpl : public PhysicImpl
	{
	public:
		NullPhysicImpl( void ) { inc_ref();	}

		virtual b2Vec2 GetPosition(void) const
		{ return b2Vec2_zero; }

		virtual void SetPosition(const b2Vec2& pos) { }

		virtual b2Vec2 GetVelocity(void) const
		{ return b2Vec2_zero; }

		virtual void SetVelocity(const b2Vec2& pos) { }

		virtual Radians GetAngle(void) const
		{ return Radians(0.f); }

		virtual void SetAngle(Radians angle) { }

		virtual float GetOmega(void) const
		{ return 0.f; }

		virtual void SetOmega(float omega) { }

		virtual GameObject& GetParent( void ) const
		{ return *reinterpret_cast<GameObject*>(NULL); }

		virtual b2Body& engine_GetBody( void )
		{ return *reinterpret_cast<b2Body*>(NULL); }
	};

	NullPhysicImpl null_impl; //< null object

} // anonymous namespace

Physic::Physic( void )
 : m_pimpl( &null_impl )
{ }

Physic::Physic( const PhysicPimpl& pimpl )
 : m_pimpl( pimpl )
{ }

b2Vec2 Physic::GetPosition( void ) const
{ return m_pimpl->GetPosition();	}

void Physic::SetPosition( const b2Vec2& pos )
{ m_pimpl->SetPosition( pos ); }

b2Vec2 Physic::GetVelocity( void ) const
{ return m_pimpl->GetVelocity();	}

void Physic::SetVelocity( const b2Vec2& vel )
{ m_pimpl->SetVelocity(vel); }

Radians Physic::GetAngle( void ) const
{ return m_pimpl->GetAngle();	}

void Physic::SetAngle( Radians angle )
{ m_pimpl->SetAngle(angle); }

float Physic::GetOmega( void ) const
{ return m_pimpl->GetOmega();	}

void Physic::SetOmega( float omega )
{ m_pimpl->SetOmega(omega); }

GameObject& Physic::GetParent( void ) const
{ return m_pimpl->GetParent();	}

b2Body& Physic::engine_GetBody( void )
{ return m_pimpl->engine_GetBody(); }

} // ammo
